package com.augurit.wf.jbpmex.task.multitask.proxy;

import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;

import com.augurit.wf.jbpmex.task.multitask.MultiTaskDefinition;

public class MultiTaskProxyFactory {
	
	public static final String EQUAL = "equal";	//对等模式
	public static final String MAIN_SYNC = "main-sync";	//同步主协模式
	public static final String MAIN_ASYNC = "main-async"; //异步主协模式

	
	public static final IModeProxy getProxy(TaskDefinitionImpl taskDefinition, ExecutionImpl execution){
		
		MultiTaskDefinition multiTaskDefinition = taskDefinition.getMultiTaskDefinition();
		
		if(multiTaskDefinition != null && multiTaskDefinition.getMode() != null){
			
			if(multiTaskDefinition.getMode().equals(EQUAL))
				return new EqualModeProxy(taskDefinition, execution);
			
			if(multiTaskDefinition.getMode().equals(MAIN_ASYNC))
				return new MainAsyncModeProxy(taskDefinition, execution);
			
			if(multiTaskDefinition.getMode().equals(MAIN_SYNC))
				return new MainSyncModeProxy(taskDefinition, execution);
		}
		return null;
	}
}
